<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/views/include/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@ include file="/views/include/nocachehead.jsp"%>
<title>修改密码</title>
<%@ include file="/views/include/resource.jsp"%>
<script type="text/javascript">
	ResetPassword = {
		checkPassword : function() {
			var newPassword = document.getElementById("newPassword").value;
			var newPasswordError = document.getElementById("newPasswordError");
			if (newPassword == "") {
				newPasswordError.innerHTML = "密码不能为空";
				return false;
			} else if (newPassword.length < 6) {
				newPasswordError.innerHTML = "密码不能小于6位";
				return false;
			} else if (newPassword.length > 32) {
				newPasswordError.innerHTML = "密码不能超过32位";
				return false;
			} else {
				newPasswordError.innerHTML = "";
				return true;
			}
		},
		checkPasswordConfirm : function() {
			var newPassword = document.getElementById("newPassword").value;
			var newPasswordConfirm = document
					.getElementById("newPasswordConfirm").value;
			var newPasswordConfirmError = document
					.getElementById("newPasswordConfirmError");
			if (newPasswordConfirm == "") {
				newPasswordConfirmError.innerHTML = "密码不能为空";
				return false;
			} else if (newPasswordConfirm.length < 6) {
				newPasswordConfirmError.innerHTML = "密码不能小于6位";
				return false;
			} else if (newPasswordConfirm.length > 32) {
				newPasswordConfirmError.innerHTML = "密码不能超过32位";
				return false;
			} else if (newPasswordConfirm != newPassword) {
				newPasswordConfirmError.innerHTML = "两次密码输入不一致";
				return false;
			} else {
				newPasswordConfirmError.innerHTML = "";
				return true;
			}
		},
		reset : function() {
			if (ModifyPassword.checkPassword()
					&& ModifyPassword.checkPasswordConfirm()) {
				var resetPasswordForm = document
						.getElementById("resetPasswordForm");
				resetPasswordForm.submit();
			}
		}
	}
</script>
</head>
<body>
	<h1>修改密码</h1>
	<hr>
	<c:set var="errorMessage" value="${requestScope.errorMessage }"> </c:set>
	<c:if test="${errorMessage ne null }">
		<font color="red">
			${errorMessage }<br>
			您还可以尝试<b>${3- sessionScope.SESSION_MIDIFY_PSWD_TRY_TIME }</b>
		</font>
	</c:if>
	<form
		action="${pageContext.request.contextPath}/user/password/modify.html"
		method="post">
		<table>
			<tr>
				<td>原密码:</td>
				<td><input type="password" name="password" id="password"
					size="32">
				</td>
				<td></td>
			</tr>
			<tr>
				<td>新密码:</td>
				<td><input type="password" name="newPassword" id="newPassword"
					size="32" onblur="javascript:ModifyPassword.checkPassword();">
				</td>
				<td><font id="newPasswordError" color="red"></font>
				</td>
			</tr>
			<tr>
				<td>确认新密码:</td>
				<td><input type="password" name="newPasswordConfirm"
					id="newPasswordConfirm" size="32"
					onblur="javascript:ModifyPassword.checkPasswordConfirm();">
				</td>
				<td><font id="newPasswordConfirmError" color="red"></font>
				</td>
			</tr>
			<tr>
				<td colspan="2"><input type="button"
					onclick="javascript:ModifyPassword.modify();" value="提交"></td>
				<td></td>
			</tr>
		</table>
	</form>
</body>
</html>